/*
 * Copyright 2011-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0.
 * See `LICENSE` in the project root for license information.
 */

package me.ijleex.mgmt.system.auth.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import me.ijleex.mgmt.framework.entity.Result;
import me.ijleex.mgmt.system.auth.service.IAuthService;

/**
 * AuthAction.
 *
 * @author liym
 * @since 2020-08-09 15:50 新建
 */
@RequestMapping(value = "/auth", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@RestController
public class AuthAction {

    private final IAuthService authService;

    public AuthAction(IAuthService authService) {
        this.authService = authService;
    }

    @PostMapping("/login")
    public Result login(HttpServletRequest request, String login, String password) {
        return this.authService.login(login, password);
    }

    @PostMapping("/register")
    public Result register(HttpServletRequest request, String login, String password, String captchaCode) {
        return this.authService.register(login, password, captchaCode);
    }

}
